home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14347 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: nntp.develop.bsis.com!usenet
  2. From: Leonard Lehew <leonard.lehew@bsis.com>
  3. Newsgroups: comp.lang.smalltalk,comp.object,comp.lang.c++,comp.lang.java
  4. Subject: Re: The Good, the Bad, the Ugly, and the Wicked ...
  5. Date: Wed, 27 Mar 1996 16:32:21 -0500
  6. Organization: Broadway and Seymour
  7. Message-ID: <3159B3E5.5281@bsis.com>
  8. References: <31570B8E.5A12@vmark.com> <31586721.1750@mobius.net> <4jbk0m$jt9@news4.digex.net> <AD7EDB45966858C12@mac-sandvik.engr.sgi.com>
  9. NNTP-Posting-Host: bsi16_83.bsis.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (WinNT; I)
  14.  
  15. Kent Sandvik wrote:
  16. > In article <4jbk0m$jt9@news4.digex.net>,
  17. > ell@access1.digex.net (Ell) wrote:
  18. >   >racer-x (pauly@mobius.net) wrote:
  19. >   >: ...Maybe it's just me, but I didn't even realize C++ had
  20. >   >: dynamic binding.
  21. >   >
  22. >   >Guess what?  It is you.  :-)
  23. >   >
  24. >   >C++ very much has dynamic binding; lookup virtual functions.
  25. > It depends how you defined dynamic binding, could you send messages to
  26. > arbitrary methods in C++ during runtime (or java, by the way)?
  27. > --Kent
  28. >           Kent Sandvik, Silicon Graphics, Inc.    Member of Technical Staff
  29. >                              Email: sandvik@sgi.com  Phone: +1 415 933-6417
  30. >                     http://reality.sgi.com/sandvik/  (sgi http:/kent.engr/)
  31. >                                              "May all developers be happy."It all depends on how you define dynamic binding. 
  32.  
  33. C++ implements dynamic binding through virtual methods. When a virtual 
  34. member function is invoked (i.e., when a message is sent to an object)
  35. the actual run time object must be of the class the compiler "expects" or
  36. it must be of a class derived from the "expected" class. This means
  37. that the polymorphism only extends to classes which are part of the
  38. same inheritance tree.
  39.  
  40. Smalltalk by comparison does not impose this restriction. You can send
  41. any message selector to any object at runtime. If the receiving object
  42. has a corresponding method, it will be invoked, regardless of its
  43. inheritance.
  44.  
  45. Which is better depends on your perspective and needs. The strong type
  46. checking in C++ detects certain errors before testing, and C++ apps
  47. generally perform better. On the other hand, there are many circumstances
  48. where I want polymorphic behavior, and inheritance is just not the most
  49. natural, convenient, or elegant way to achieve it.
  50.  
  51.  
  52. Leonard Lehew
  53. Broadway & Seymour
  54.